<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>我要评论</title>
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" type="text/css" href="../js/layui/layui-v2.4.5/layui/css/layui.css"/>
	<link rel="stylesheet" type="text/css" href="../css/woyaopinglun.css">
    <link rel="stylesheet" type="text/css" href="../css/city1.css">

    <link href="../img/1-t.png" rel="SHORTCUT ICON" />
    <style type="text/css">
        .shade {
            position: absolute;
            display: none;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            background: rgba(0, 0, 0, 0.55);
        }

        .shade div {
            width: 300px;
            height: 200px;
            line-height: 200px;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -100px;
            margin-left: -150px;
            background: white;
            border-radius: 5px;
            text-align: center;
        }

        .a-upload {
            margin-left: 20px;
            font-size: 14px;
            padding: 50px 32px;
            height: 20px;
            line-height: 20px;
            position: relative;
            cursor: pointer;
            color: #888;
            background: #fafafa;
            border: 1px solid #ddd;
            border-radius: 4px;
            overflow: hidden;
            display: inline-block;
            *display: inline;
            *zoom: 1
        }

        .a-upload input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
            filter: alpha(opacity=0);
            cursor: pointer
        }

        .a-upload:hover {
            color: #444;
            background: #eee;
            border-color: #ccc;
            text-decoration: none
        }
        .img_div{max-width: 570px;}
        .isImg{width: 120px; height: 120px; position: relative; float: left; margin-left: 20px;}
        .removeBtn{position: absolute; top: 0; right: 0; z-index: 11; border: 0px; border-radius: 50px; background: red; width: 22px; height: 22px; color: white;}
        .shadeImg{position: absolute;
            display: none;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 15;
            text-align: center;
            background: rgba(0, 0, 0, 0.55);}
        .showImg{width: 500px; height: 500px; margin-top: 140px;}

    </style>

    <script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="../js/layui/layui-v2.4.5/layui/layui.all.js"></script>

</head>
<body>
    <nav class="clearfix">
        <div class="nav clearfix">
            <a class="logo fl" href="./shouye.html">
                <img src="../img/1-logo-white.3de707b4.png" alt="">
            </a>
            <div class="city-name fl dingwei" style="color:#fff;margin-left:20px;font-size:14px;width: 50px;background:  url(../img/1-arr-down.9f1dbfdd.png) no-repeat right center;">上海</div>
            <ul class="lei fl">
                <!-- <li class="fl"><a href="javascript:;">首页</a></li> -->
                <li class="ashow fl"><a href="javascript:;">全部演出</a>
                    <div class="submenu">
                        <ul class="allshow">
                            <li>
                                <a href="javascript:;">演唱会</a>
                            </li>
                            <li>
                                <a href="javascript:;">话剧歌剧</a>
                            </li>
                            <li>
                                <a href="javascript:;">休闲展览</a>
                            </li>
                            <li>
                                <a href="javascript:;">体育赛事</a>
                            </li>
                            <li>
                                <a href="javascript:;">音乐会</a>
                            </li>
                            <li>
                                <a href="javascript:;">儿童亲子</a>
                            </li>
                            <li>
                                <a href="javascript:;">舞蹈芭蕾</a>
                            </li>
                            <li>
                                <a href="javascript:;">戏曲综艺</a>
                            </li>
                        </ul>
                    </div>
                    
                </li>
                <li class="fl"><a href="javascript:;">发现</a></li>
                <li class="fl"><a href="javascript:;">十分现场</a></li>
            </ul>
            <div class="search fl">
                <input class="fl" type="text" placeholder="搜索演出、明星、场馆">
                <img src="../img/1-icon-search.c1ea7e12.png" alt="搜索">
            </div>
            <div class="right fr">
                <a class="fl" href="javascript:;">登录</a>
                <span class="fl">|</span>
                <div class="app fl">手机票牛
                    <div class="submenu1">
                        <ul class="appshow">
                            <li class="clearfix">
                                <img  class="img1 fl" src="../img/1-qr-app.a2c8e636.png" width="84px" >
                                <div class="text fr"> 
                                    <div class="title">票牛APP</div>
                                    <div class="desc">热门票随时抢<br>折扣票随时买</div>
                                </div>
                            </li>
                            <li class="clearfix">
                                <div class="img2 fl"><img src="../img/1-qr-wechat.eceb0fc5.png"  height="84px"></div>
                                
                                <div class="text fr">
                                    <p class="title1">微信订阅号</p>
                                    <p class="desc">精彩剧评最新<br>活动随时看</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </nav>
    
	<div class="cont">
		<div class="content">
			<div class="left">
				<div class="rating">
					<span class="text_t">请评分：</span>
					<div id="test3" class="layui-inline rat"></div>
				</div>
				<div class="comment">
					<span class="text_r">评价：</span>
					<textarea class="comment_text" placeholder="写下该演出的评价吧..." class="textarea"></textarea>
				</div>

                    <div class="uppes">
                        <span>上传图片：</span>
                        <div>
                            <a href="javascript:;" class="a-upload">
                                <input class="upps" type="file" name="myFile" id="myFile" multiple="multiple" />上传图片<br/>最多九张
                            </a>
                            <div class="img_div"></div>
                            <div class="shade" onclick="javascript:closeShade()">
                                <div class="">
                                    <span class="text_span"></span>
                                </div>
                            </div>
                            <div class="shadeImg" onclick="javascript:closeShadeImg()">
                                <div class="">
                                    <img class="showImg" src="">
                                </div>
                            </div>
                        </div>
                    </div>
                <form id="form">
                    <div style="display: none;">
                        <input name="userId" class="userId"/>
                        <input name="commodityId" class="commodityId"/>
                        <input name="level" class="level"/>
                        <input name="content" class="content"/>
                        <input name="fatherId" class="fatherId" value="0"/>
                        <input name="belongToId" class="belongToId" value="0"/>
                        <input name="imgId" class="imgId" value="0"/>
                    </div>
                </form>

            <button class="btn" id="addMain">发表</button>

		</div>

            <div class="right1">
                <div class="cont_top">
                    <h3><a href="">《哪吒》 真人巡回演出，带你回忆童年 山西站</a></h3>
                    <p class="num_x">
						<span>
							<strong>10.</strong>
							<i>0</i>
							<img src="../img/1-star-full.04f7ab77.png">
							<img src="../img/1-star-full.04f7ab77.png">
							<img src="../img/1-star-full.04f7ab77.png">
							<img src="../img/1-star-full.04f7ab77.png">
							<img src="../img/1-star-full.04f7ab77.png">
						</span>
                    </p>
                    <div class="list">
                        <a href=""><img src="../img/1-243d6c6f7d30ee5c61c0f1bd77634e3e570e3f82.jpg"></a>
                        <div class="lisr_r">
                            <p class="list_text"><a href="">山西省体育中心体育馆</a></p>
                            <p class="list_text"><a href="">2019.08.04 - 2019.08.31</a></p>
                            <div class="list_bottom">
                                <p class="blk_blue"><a href="">售票中</a></p>
                                <p class="price">￥<strong>420</strong><span>起</span></p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="cont_buttom">
                    <div>
                        <a href=""><img src="../img/1-qr-app.a2c8e636.png"></a>
                    </div>
                    <div>
                        <h4><a href="#">票牛APP</a></h4>
                        <p><a href="#">热门票随时抢<br>折扣票随时买</a></p>
                    </div>
                </div>
            </div>
	    </div>

    </div>
    <!-- 尾部 -->
    <div class="db" style="color:#919496;">
            
        <p style="color:#919496;font-size:12px">上海颂品网络科技有限公司 Copyright (c) 2015年 Songpin. All rights reserved. <a href="http://www.miitbeian.gov.cn/" target="_black" class="aa">| 沪ICP备14000399号-2</a></p>
        <div class="db1">
            <p><img src="../img/1-j.jpg" alt=""><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=31010602001682" target="_black" class="aa">沪公网安备31010602001682号</a></p>
            <span><img src="../img/1-j2.jpg" alt=""><a href="http://www.sgs.gov.cn/lz/licenseLink.do?method=licenceView&entyId=2016050618242638" class="aa">上海工商</a></span>
        </div>
    </div>  

     <!-- 上海 -->
    <div>
    <!-- <div class="city-name">上海</div> -->
    
        <div class="citylist" style="display: none">
              <div class="top-rows">
                <div class="row">
                  <div class="title" style="width: 63px">当前城市：</div>
                      <ul>
                        <li class="selected dingwei2" data-name="shanghai">上海</li>
                      </ul>
                </div>
                <div class="row">
                  <div class="title" style="width: 63px">热门城市：</div>
                  <ul class="asdf">
                    <li class="city-item" data-name="shanghai">上海</li>
                    <li class="city-item" data-name="beijing">北京</li>
                    <li class="city-item" data-name="guangzhou">广州</li>
                    <li class="city-item" data-name="shenzhen">深圳</li>
                    <li class="city-item" data-name="chengdu">成都</li>
                    <li class="city-item" data-name="chongqing">重庆</li>
                    <li class="city-item" data-name="tianjin">天津</li>
                    <li class="city-item" data-name="hangzhou">杭州</li>
                    <li class="city-item" data-name="nanjing">南京</li>
                    <li class="city-item" data-name="wuhan">武汉</li>
                    <li class="city-item" data-name="xian">西安</li>
                    <li class="city-item" data-name="changsha">长沙</li>
                    <li class="city-item" data-name="kunming">昆明</li>
                  </ul>
                </div>
              </div>
              <div class="city-indexes">
                <div class="title">按字母查找</div>
                <ul class="hot-city-capitcals">
                  <li class="cap" id="a">A</li><li class="cap" id="b">B</li><li class="cap" id="c">C</li><li class="cap" id="d">D</li><li class="cap" id="f">F</li><li class="cap" id="g">G</li><li class="cap" id="h">H</li><li class="cap" id="j">J</li><li class="cap" id="k">K</li><li class="cap" id="l">L</li><li class="cap" id="m">M</li><li class="cap" id="n">N</li><li class="cap" id="p">P</li><li class="cap" id="q">Q</li><li class="cap" id="r">R</li><li class="cap" id="s">S</li><li class="cap" id="t">T</li><li class="cap" id="w">W</li><li class="cap" id="x">X</li><li class="cap" id="y">Y</li><li class="cap" id="z">Z</li>
                </ul>
              </div>
              <div class="hot-cities">
                <ul id="cityUl">
                  <li data-capital="A" id="A">
                      <div class="capital">A</div>
                      <ul class="items">
                        <div class="item city-item" data-name="anshun">安顺</div><div class="item city-item" data-name="macau">澳门</div>
                      </ul>
                 </li>
                 <li data-capital="B" id="B">
                      <div class="capital">B</div>
                      <ul class="items">
                        <div class="item city-item" data-name="bangkok">曼谷</div><div class="item city-item" data-name="baoding">保定</div><div class="item city-item" data-name="baotou">包头</div><div class="item city-item" data-name="beihai">北海</div><div class="item city-item" data-name="beijing">北京</div><div class="item city-item" data-name="bengbu">蚌埠</div><div class="item city-item" data-name="benxi">本溪</div><div class="item city-item" data-name="binzhou">滨州</div>
                      </ul>
                </li>
                <li data-capital="C" id="C">
                      <div class="capital">C</div>
                      <ul class="items">
                        <div class="item city-item" data-name="changchun">长春</div><div class="item city-item" data-name="changsha">长沙</div><div class="item city-item" data-name="changshu">常熟</div><div class="item city-item" data-name="changzhou">常州</div><div class="item city-item" data-name="chengde">承德</div><div class="item city-item" data-name="chengdu">成都</div><div class="item city-item" data-name="chongqing">重庆</div>
                      </ul>
                </li>
                <li data-capital="D" id="D"> 
                      <div class="capital">D</div>
                      <ul class="items">
                        <div class="item city-item" data-name="dalian">大连</div><div class="item city-item" data-name="daqing">大庆</div><div class="item city-item" data-name="deyang">德阳</div><div class="item city-item" data-name="dezhou">德州</div><div class="item city-item" data-name="dongguan">东莞</div><div class="item city-item" data-name="dongying">东营</div>
                      </ul>
                </li>
                <li data-capital="F" id="F">
                      <div class="capital">F</div>
                      <ul class="items">
                        <div class="item city-item" data-name="foshan">佛山</div><div class="item city-item" data-name="fushun">抚顺</div><div class="item city-item" data-name="fuzhou">福州</div>
                      </ul>
                </li>
                <li data-capital="G" id="G">
                      <div class="capital">G</div>
                      <ul class="items">
                        <div class="item city-item" data-name="ganzhou">赣州</div><div class="item city-item" data-name="guangan">广安</div><div class="item city-item" data-name="guangxiyulin">玉林</div><div class="item city-item" data-name="guangzhou">广州</div><div class="item city-item" data-name="guilin">桂林</div><div class="item city-item" data-name="guiyang">贵阳</div>
                      </ul>
                </li>
                <li data-capital="H" id="H">
                      <div class="capital">H</div>
                      <ul class="items">
                        <div class="item city-item" data-name="haerbin">哈尔滨</div><div class="item city-item" data-name="haikou">海口</div><div class="item city-item" data-name="handan">邯郸</div><div class="item city-item" data-name="hangzhou">杭州</div><div class="item city-item" data-name="hefei">合肥</div><div class="item city-item" data-name="hengshui">衡水</div><div class="item city-item" data-name="hengyang">衡阳</div><div class="item city-item" data-name="heyuan">河源</div><div class="item city-item" data-name="huaian">淮安</div><div class="item city-item" data-name="huanggang">黄冈</div><div class="item city-item" data-name="huhehaote">呼和浩特</div><div class="item city-item" data-name="huizhou">惠州</div><div class="item city-item" data-name="huzhou">湖州</div>
                      </ul>
                </li>
                <li data-capital="J" id="J">
                      <div class="capital">J</div>
                      <ul class="items">
                        <div class="item city-item" data-name="jiangmen">江门</div><div class="item city-item" data-name="jiangxiyichun">宜春</div><div class="item city-item" data-name="jiaxing">嘉兴</div><div class="item city-item" data-name="jilin">吉林</div><div class="item city-item" data-name="jinan">济南</div><div class="item city-item" data-name="jingzhou">荆州</div><div class="item city-item" data-name="jinhua">金华</div><div class="item city-item" data-name="jining">济宁</div><div class="item city-item" data-name="jiujiang">九江</div>
                      </ul>
                </li>
                <li data-capital="K" id="K">
                      <div class="capital">K</div>
                      <ul class="items">
                        <div class="item city-item" data-name="kunming">昆明</div><div class="item city-item" data-name="kunshan">昆山</div>
                      </ul>
                </li>
                <li data-capital="L" id="L">
                      <div class="capital">L</div>
                      <ul class="items">
                        <div class="item city-item" data-name="langfang">廊坊</div><div class="item city-item" data-name="lanzhou">兰州</div><div class="item city-item" data-name="lasvegas">拉斯维加斯</div><div class="item city-item" data-name="leshan">乐山</div><div class="item city-item" data-name="lianyuangang">连云港</div><div class="item city-item" data-name="liaocheng">聊城</div><div class="item city-item" data-name="linyi">临沂</div><div class="item city-item" data-name="lishui">丽水</div><div class="item city-item" data-name="liuzhou">柳州</div><div class="item city-item" data-name="luoyang">洛阳</div>
                      </ul>
                </li>
                <li data-capital="M" id="M">
                      <div class="capital">M</div>
                      <ul class="items">
                        <div class="item city-item" data-name="maanshan">马鞍山</div><div class="item city-item" data-name="maoming">茂名</div><div class="item city-item" data-name="mianyang">绵阳</div><div class="item city-item" data-name="moscow">莫斯科</div><div class="item city-item" data-name="mudanjiang">牡丹江</div>
                      </ul>
                </li>
                <li data-capital="N" id="N">
                      <div class="capital">N</div>
                      <ul class="items">
                        <div class="item city-item" data-name="nanchang">南昌</div><div class="item city-item" data-name="nanjing">南京</div><div class="item city-item" data-name="nanning">南宁</div><div class="item city-item" data-name="nantong">南通</div><div class="item city-item" data-name="ningbo">宁波</div>
                      </ul>
                </li>
                <li data-capital="P" id="P">
                      <div class="capital">P</div>
                      <ul class="items">
                        <div class="item city-item" data-name="pingxiang">萍乡</div>
                      </ul>
                </li>
                <li data-capital="Q" id="Q">
                      <div class="capital">Q</div>
                      <ul class="items">
                        <div class="item city-item" data-name="qianjiang">潜江</div><div class="item city-item" data-name="qingdao">青岛</div><div class="item city-item" data-name="qingyuan">清远</div><div class="item city-item" data-name="qinhuangdao">秦皇岛</div><div class="item city-item" data-name="quanzhou">泉州</div>
                      </ul>
                </li>
                <li data-capital="R" id="R">
                      <div class="capital">R</div>
                      <ul class="items">
                        <div class="item city-item" data-name="rizhao">日照</div><div class="item city-item" data-name="russia">俄罗斯</div>
                      </ul>
                </li>
                <li data-capital="S" id="S">
                      <div class="capital">S</div>
                      <ul class="items">
                        <div class="item city-item" data-name="sanya">三亚</div><div class="item city-item" data-name="shanghai">上海</div><div class="item city-item" data-name="shantou">汕头</div><div class="item city-item" data-name="shaoxing">绍兴</div><div class="item city-item" data-name="shenyang">沈阳</div><div class="item city-item" data-name="shenzhen">深圳</div><div class="item city-item" data-name="shijiazhuang">石家庄</div><div class="item city-item" data-name="singapore">新加坡</div><div class="item city-item" data-name="suining">遂宁</div><div class="item city-item" data-name="suzhou">苏州</div>
                      </ul>
                </li>
                <li data-capital="T" id="T">
                      <div class="capital">T</div>
                      <ul class="items">
                        <div class="item city-item" data-name="taian">泰安</div><div class="item city-item" data-name="taiyuan">太原</div><div class="item city-item" data-name="taizhou">泰州</div><div class="item city-item" data-name="tangshan">唐山</div><div class="item city-item" data-name="tianjin">天津</div>
                      </ul>
                </li>
                <li data-capital="W" id="W">
                      <div class="capital">W</div>
                      <ul class="items">
                        <div class="item city-item" data-name="weifang">潍坊</div><div class="item city-item" data-name="weihai">威海</div><div class="item city-item" data-name="wenzhou">温州</div><div class="item city-item" data-name="wuhan">武汉</div><div class="item city-item" data-name="wuhu">芜湖</div><div class="item city-item" data-name="wulumuqi">乌鲁木齐</div><div class="item city-item" data-name="wuxi">无锡</div><div class="item city-item" data-name="wuzhou">梧州</div>
                      </ul>
                </li>
                <li data-capital="X" id="X">
                      <div class="capital">X</div>
                      <ul class="items">
                        <div class="item city-item" data-name="xiamen">厦门</div><div class="item city-item" data-name="xian">西安</div><div class="item city-item" data-name="hongkong">香港</div><div class="item city-item" data-name="xuzhou">徐州</div>
                      </ul>
                </li>
                <li data-capital="Y" id="Y">
                      <div class="capital">Y</div>
                      <ul class="items">
                        <div class="item city-item" data-name="yancheng">盐城</div><div class="item city-item" data-name="yangzhou">扬州</div><div class="item city-item" data-name="yantai">烟台</div><div class="item city-item" data-name="yibin">宜宾</div><div class="item city-item" data-name="yichang">宜昌</div><div class="item city-item" data-name="yinchuan">银川</div><div class="item city-item" data-name="yingkou">营口</div><div class="item city-item" data-name="yiwu">义乌</div><div class="item city-item" data-name="yulin">榆林</div>
                      </ul>
                </li>
                <li data-capital="Z" id="Z">
                      <div class="capital">Z</div>
                      <ul class="items">
                        <div class="item city-item" data-name="zaozhuang">枣庄</div><div class="item city-item" data-name="zhangjiakou">张家口</div><div class="item city-item" data-name="zhangqiu">章丘</div><div class="item city-item" data-name="zhanjiang">湛江</div><div class="item city-item" data-name="zhaoqing">肇庆</div><div class="item city-item" data-name="zhejiangtaizhou">台州</div><div class="item city-item" data-name="zhengzhou">郑州</div><div class="item city-item" data-name="zhenjiang">镇江</div><div class="item city-item" data-name="zhongshan">中山</div><div class="item city-item" data-name="zhoushan">舟山</div><div class="item city-item" data-name="zhuhai">珠海</div><div class="item city-item" data-name="zhuzhou">株洲</div><div class="item city-item" data-name="zibo">淄博</div><div class="item city-item" data-name="zigong">自贡</div><div class="item city-item" data-name="zunyi">遵义</div>
                      </ul>
                    </li>
                </ul>
              </div>
            </div>
    </div>
    <div id="allmap"></div>
</body>
</html>

<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=a2KhD9EGeKHLLsFaujVVnBmut0Al8vqt"></script>
<script type="text/javascript" src="../js/position.js"></script>-->
<script type="text/javascript">
var level;
var userId;//用户id
var commodityId;//商品id
var num=0;
layui.use(['rate'], function(){
    rate= layui.rate;
 	rate.render({
	 	elem: '#test3'
		,value: 0 //初始值
		,half: false //不开启半星
        ,choose: function (value) {
            level=value;
        }
  	})
})

var fileData = new FormData();
$(function () {
    commodityId=getUrlParam('commodityId');
    if(commodityId==undefined){
        commodityId=6;//定死商品的值
    }else{
        $(".commodityId").val(commodityId);
    }
    userId=getUrlParam('userId');
    if(userId==undefined){
        userId=15;//定死用户id的值
    }


    //添加主评论时
    $("#addMain").click(function () {
        //获取评论内容
        var content=$(".comment_text").val();
        if(content==null||content==undefined||content==""){
            layer.msg('请填写内容哦~', {
                time: 2000, //2s后自动关闭
            });
            return;
        }
        else{
            if(fileData.has("file")){//有图片
                //先上传图片
                $.ajax({
                    async : false,
                    traditional: true,
                    type: "POST",
                    url: "http://cn.pn.com/api-pn/comment/api/p/fileUpload",
                    data: fileData,
                    cache: false, //上传文件不需要缓存
                    dataType: "json",
                    processData: false, // 告诉jQuery不要去处理发送的数据
                    contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                    success: function (data) {//上传图片成功后再去添加数据
                        layer.msg('上传图片成功！', {
                            time: 2000, //2s后自动关闭
                        });
                        console.log("添加的图片id："+data)
                        setTimeout(function () {
                            addMainComment(data,content); //新增数据
                        },1000)
                    },
                    error: function () {
                        layer.msg('上传图片失败！评论失败！请尝试刷新后重试~', {
                            time: 2000, //2s后自动关闭
                        });
                    }
                });
            }else{//无图片
                addMainComment(0,content);
            }
        }
    });


    var objUrl;
    var img_html;
    $("#myFile").change(function() {
        //获取选择图片的对象
        var docObj = $(this)[0];
        var img_div = $(".img_div");
        var filepath = $("input[name='myFile']").val();
        //先判断是否为图片并添加节点
        for(var i = 0; i < this.files.length; i++) {
            objUrl = getObjectURL(this.files[i]);
            var extStart = filepath.lastIndexOf(".");
            var ext = filepath.substring(extStart, filepath.length).toUpperCase();
            //描述:鉴定每个图片上传尾椎限制
            if(ext != ".BMP" && ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
                $(".shade").fadeIn(500);
                $(".text_span").text("图片限于bmp,png,gif,jpeg,jpg格式");
                this.value = "";
                $(".img_div").html("");
                return false;
            }
            else {
                //若规则全部通过则在此提交url到后台数据库
                img_html = "<div class='isImg'><img id='"+this.files[i].name+"' src='" + objUrl + "' onclick='javascript:lookBigImg(this)' style='height: 100%; width: 100%;' /><button class='removeBtn' onclick='javascript:removeImg(this)'>x</button></div>";
                img_div.append(img_html);
            }
        }
        //将图片数据放到formData中传递后台
        if($(this)[0].files.length==1){
            fileData.append("file",docObj.files[0]);
        }else{
            for(var i=0; i<$(this)[0].files.length;i++){
                fileData.append("file",$(this)[0].files[i]);
            }
        }
        /*

        //鉴定每个图片大小总和
        var file_size = 0;
        var all_size = 0;
        for(j = 0; j < this.files.length; j++) {
            file_size = this.files[j].size;
            all_size = all_size + this.files[j].size;
            var size = all_size / 1024;
            if(size > 500) {
                $(".shade").fadeIn(500);
                $(".text_span").text("上传的图片大小不能超过100k！");
                this.value = "";
                $(".img_div").html("");
                return false;
            }
        }
        return true;
        */
    });

    //鉴定每个浏览器上传图片url 目前没有合并到Ie
    function getObjectURL(file) {
        var url = null;
        if(window.createObjectURL != undefined) { // basic
            url = window.createObjectURL(file);
        } else if(window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if(window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        //console.log(url);
        return url;
    }
});



//提交无图评论
function addMainComment(imgId,content) {
    //获取星级
    if(level==undefined){
        level=0;
    }
    $(".level").val(level);
    $(".content").val(content);
    $(".userId").val(userId);
    $(".commodityId").val(commodityId);
    $(".imgId").val(imgId);
    //提交文字数据
    $.ajax({
        type: "POST",
        url: "http://cn.pn.com/api-pn/comment/api/p/add",
        data: $("#form").serialize(),
        dataType: "json",
        success: function (data) {
            layer.msg('评论成功！', {
                time: 2000, //2s后自动关闭
            });
        },
        error: function () {
            layer.msg('评论失败！请尝试刷新后重试', {
                time: 2000, //2s后自动关闭
            });
        }
    });
}



/*
  描述：上传图片附带删除 再次地方可以加上一个ajax进行提交到后台进行删除
 * */
function removeImg(r){
    $(r).parent().remove();
    num--;
}
/*
  描述：上传图片附带放大查看处理
 * */
function lookBigImg(b){
    $(".shadeImg").fadeIn(500);
    $(".showImg").attr("src",$(b).attr("src"))
}
/*
  描述：关闭弹出层
 * */
function closeShade(){
    $(".shade").fadeOut(500);
}
/*
  描述：关闭弹出层
 */
function closeShadeImg(){
    $(".shadeImg").fadeOut(500);
}

//获取url中的commodityId参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}

</script>
